/**
 * Project:   dtu.fmes.googleloon
 * File:      KillDischargedBalloonsSimulationLink.java
 * License: 
 *            This file is licensed under GNU General Public License version 3
 *            http://www.gnu.org/licenses/gpl-3.0.txt
 *
 * Copyright:	Bartosz Cichecki [ cichecki.bartosz@gmail.com ]
 * 				Nicolai Sonne [ NicolaiSonne@hotmail.com.com ]
 * Date:      Dec 11, 2013
 */

package dtu.fmes.loon.simulation.processors;

import dtu.fmes.loon.model.Balloon;

/**
 * Kills balloons if they have run out of power
 * Resurrects balloons if they have started charging again
 * Can't resurrect balloons if "canBeRevived" flag have been disabled
 * 
 * @author Bartosz Cichecki, Nicolai Sonne
 * 
 */
public class KillDischargedBalloonsSimulationLink extends SimulationLink {

	@Override
	public void run() {
		for (Balloon b : css.getBalloons()) {
			if (b.isAlive() && b.getCurrentBatteryCapacity() <= 0) {
				b.setCurrentBatteryCapacity(0.0);
				b.setAlive(false);
			} else if (b.isCanBeRevived()) {
				b.setAlive(true);
			}
		}
	}

}
